home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / System 7.0 Samples / Kibitz / Chess.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-06  |  5.6 KB  |  160 lines  |  [TEXT/MPS ]

  1. #ifndef __CHESS__
  2. #define __CHESS__
  3.  
  4. #ifndef __TYPES__
  5. #include <types.h>
  6. #endif
  7.  
  8. #ifndef __APPLEEVENTS__
  9. #include <AppleEvents.h>
  10. #endif
  11.  
  12. #ifndef __PRINTING__
  13. #include <Printing.h>
  14. #endif
  15.  
  16.  
  17. #define WHITE 0
  18. #define BLACK 1
  19.  
  20. #define QSIDE 0
  21. #define KSIDE 1
  22.  
  23. #define EMPTY    0
  24. #define PAWN    1
  25. #define KNIGHT    2
  26. #define BISHOP    3
  27. #define ROOK    4
  28. #define QUEEN    5
  29. #define KING    6
  30.  
  31. #define BP PAWN            /* Black pawn    */
  32. #define BN KNIGHT        /* Black knight    */
  33. #define BB BISHOP        /* Black bishop    */
  34. #define BR ROOK            /* Black rook    */
  35. #define BQ QUEEN        /* Black queen    */
  36. #define BK KING            /* Black king    */
  37.  
  38. #define WP -PAWN        /* White pawn    */
  39. #define WN -KNIGHT        /* White knight    */
  40. #define WB -BISHOP        /* White bishop    */
  41. #define WR -ROOK        /* White rook    */
  42. #define WQ -QUEEN        /* White queen    */
  43. #define WK -KING        /* White king    */
  44.  
  45. #define OBNDS 32767        /* Out of bounds. */
  46.  
  47. #define START_IBNDS    21        /* Start of in-bounds for the board. */
  48. #define END_IBNDS    99        /* End of in-bounds for the board. */
  49.  
  50. #define BKPOS    25
  51. #define WKPOS    95
  52.  
  53. #define kGameContinues    0
  54. #define kYouWin            1
  55. #define kYouLose        2
  56. #define kStalemate        3
  57. #define kDrawBy50        4
  58. #define kDrawByRep        5
  59. #define kYouWinOnTime    6
  60. #define kYouLoseOnTime    7
  61. #define kWhiteResigns    8
  62. #define kBlackResigns    9
  63. #define kDrawGame        10
  64. #define kWhiteWins        11
  65. #define kBlackWins        12
  66. #define kDrawButtonText    13
  67.  
  68. typedef struct {
  69.     short    kingLoc;
  70.     short    kingMoves;
  71.     short    rookMoves[2];
  72. } KingInfo;
  73.  
  74. typedef struct {
  75.     short    moveFrom;
  76.     short    moveTo;
  77.     long    value;
  78. } MoveElement;
  79. typedef MoveElement MoveList[];
  80. typedef MoveList *MoveListPtr, **MoveListHndl;
  81.  
  82. typedef struct {
  83.     short    moveFrom;
  84.     short    moveTo;
  85.     short    pieceCaptured;
  86.     short    pieceCapturedFrom;        /* For undoing en-passant. */
  87.     short    promoteTo;                /* For undoing promotions and recording games. */
  88. } GameElement;
  89. typedef GameElement GameList[];
  90. typedef GameList *GameListPtr, **GameListHndl;
  91.  
  92. typedef struct {
  93.  
  94.     short            version;            /* The file format version.                   */
  95.  
  96.     Boolean            printRecValid;        /* True if print record has been created.  */
  97.     TPrint            print;                /* Print record for file.                   */
  98.  
  99.     short            theBoard[120];        /* The current board position.               */
  100.     KingInfo        king[2];            /* King locations and castling info.       */
  101.     short            enPasMove;            /* Where an en-passant could occur.           */
  102.     short            enPasPawnLoc;        /* Location of en-passant-capture.           */
  103.     short            arngEnPasMove;        /* Initial arranged en-pas move.           */
  104.     short            arngEnPasPawnLoc;    /* Initial arranged en-pas capture.           */
  105.     short            numLegalMoves;        /* # of moves in legal move list.           */
  106.     short            gameIndex;            /* Index into game record.                   */
  107.     short            numGameMoves;        /* Size of game record.                       */
  108.     short            myColor;            /* True if I am playing black.               */
  109.     short            startColor;            /* True if black started game.               */
  110.     short            arrangeBoard;        /* True if in arrange-board mode.           */
  111.     short            palettePiece;        /* Piece hilited in arrange-board palette. */
  112.     unsigned long    defaultTime[2];        /* Default ticks for white/black.           */
  113.     unsigned long    timeLeft[2];        /* Ticks remaining for white/black.           */
  114.     Boolean            invertBoard;        /* True, display board inverted.           */
  115.     short            endFileInfo;        /* Above info is saved to disk.               */
  116.  
  117.     Boolean            twoPlayer;            /* True if playing over the net.           */
  118.     long            gameID_0;            /* Used to match up incoming moves.           */
  119.     long            gameID_1;            /* Used to match up incoming moves.           */
  120.     short            sendReason;            /* Reason for sending the game.               */
  121.     short            drawBtnState;        /* State of the draw button.                */
  122.     AEAddressDesc    locOfOpponent;        /* AppleEvents address of opponent.           */
  123.     short            endSendInfo;        /* Above is send game info.                   */
  124.  
  125.     short            resync;                /* Non-zero if resync needed.               */
  126.     Boolean            creator;            /* True if this guy originated game.       */
  127.     unsigned long    displayTime[2];        /* Time shown (is <= timeLeft).               */
  128.     unsigned long    timerRefTick;        /* Reference tick for timer.               */
  129.     unsigned long    compMoveTick;        /* Tick when computer moved last.           */
  130.     unsigned long    gotUpdateTick;        /* Tick when we received new game info.       */
  131.     Boolean            compMovesWhite;        /* True if computer moves white pieces.    */
  132.     Boolean            compMovesBlack;        /* True if computer moves black pieces.    */
  133.     char            opponentName[34];    /* User name of opponent.                   */
  134.     short            endLocalInfo;        /* Above info is for one machine only.       */
  135.  
  136.     Boolean            configColorChange;    /* True if color change has been posted.   */
  137.     short            configColor;        /* Color change value to be applied.       */
  138.     Boolean            configTimeChange;    /* True if time change has been posted.       */
  139.     unsigned long    configTime[2];        /* Time change value to be applied.           */
  140.     short            endConfigInfo;        /* Above info is config setting which will */
  141.                                         /* not be applied until a NULL event.       */
  142.  
  143.     MoveListHndl    legalMoves;            /* Handle of legal moves.                   */
  144.     GameListHndl    gameMoves;            /* Handle of game record (saved to disk).  */
  145.     TEHandle        message[2];            /* Handles to in/out messages.               */
  146.     Handle            sound;                /* Handle to recorded sound.               */
  147.     ControlHandle    sendMessage;        /* Handle to send button.                   */
  148.     ControlHandle    beepOnMove;            /* Handle to move-beep checkbox.           */
  149.     ControlHandle    beepOnMssg;            /* Handle to mssg-beep checkbox.           */
  150.     ControlHandle    gameSlider;            /* Handle to slider custom control.           */
  151.     ControlHandle    wbStart[2];            /* Handles to arrange board controls.       */
  152.     ControlHandle    resign;                /* Handle to resign button.                   */
  153.     ControlHandle    draw;                /* Handle to draw button.                   */
  154.     ControlHandle    record;                /* Handle to record sound button.           */
  155.     ControlHandle    sendSnd;            /* Handle to send sound button.               */
  156.     short            endControls;        /* Above info is reference to controls.       */
  157.  
  158. } TheDoc, *TheDocPtr, **TheDocHndl;
  159.  
  160. #endif __CHESS__